using Microsoft.Win32;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
namespace NoteManger
{
	public class NoteRemote : MarshalByRefObject
	{
		public enum TDataBaseMode
		{
			dbmAccess,
			dbmSqlServer,
			dbmOracle
		}
		private string _address = "";
		private string _username = "";
		private string _pwd = "";
		private string _databasename = "";
		private NoteRemote.TDataBaseMode iDataBaseMode = NoteRemote.TDataBaseMode.dbmSqlServer;
		[DllImport("kernel32")]
		private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
		[DllImport("kernel32")]
		private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
		public void IniWriteValue(string Section, string Key, string Value, string IniPath)
		{
			NoteRemote.WritePrivateProfileString(Section, Key, Value, IniPath);
		}
		public string IniReadValue(string Section, string Key, string IniPath)
		{
            MessageBox.Show(IniPath);
			StringBuilder stringBuilder = new StringBuilder(255);
			int privateProfileString = NoteRemote.GetPrivateProfileString(Section, Key, "", stringBuilder, 255, IniPath);
			return stringBuilder.ToString();
		}
		private static string Encrypt(string plainText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize)
		{
			byte[] bytes = Encoding.ASCII.GetBytes(initVector);
			byte[] bytes2 = Encoding.ASCII.GetBytes(saltValue);
			byte[] bytes3 = Encoding.UTF8.GetBytes(plainText);
			PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(passPhrase, bytes2, hashAlgorithm, passwordIterations);
			byte[] bytes4 = passwordDeriveBytes.GetBytes(keySize / 8);
			ICryptoTransform transform = new RijndaelManaged
			{
				Mode = CipherMode.CBC
			}.CreateEncryptor(bytes4, bytes);
			MemoryStream memoryStream = new MemoryStream();
			CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
			cryptoStream.Write(bytes3, 0, bytes3.Length);
			cryptoStream.FlushFinalBlock();
			byte[] inArray = memoryStream.ToArray();
			memoryStream.Close();
			cryptoStream.Close();
			return Convert.ToBase64String(inArray);
		}
		private static string Decrypt(string cipherText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize)
		{
			byte[] bytes = Encoding.ASCII.GetBytes(initVector);
			byte[] bytes2 = Encoding.ASCII.GetBytes(saltValue);
			byte[] array = Convert.FromBase64String(cipherText);
			PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(passPhrase, bytes2, hashAlgorithm, passwordIterations);
			byte[] bytes3 = passwordDeriveBytes.GetBytes(keySize / 8);
			ICryptoTransform transform = new RijndaelManaged
			{
				Mode = CipherMode.CBC
			}.CreateDecryptor(bytes3, bytes);
			MemoryStream memoryStream = new MemoryStream(array);
			CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Read);
			byte[] array2 = new byte[array.Length];
			int count = cryptoStream.Read(array2, 0, array2.Length);
			memoryStream.Close();
			cryptoStream.Close();
			return Encoding.UTF8.GetString(array2, 0, count);
		}
		public static string Encrypt(string aInString)
		{
			string passPhrase = "GuXueFeng";
			string saltValue = "19800629";
			string hashAlgorithm = "SHA1";
			int passwordIterations = 2;
			string initVector = "@1B2c3D4e5F6g7H8";
			int keySize = 256;
			return NoteRemote.Encrypt(aInString, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
		}
		public static string Decrypt(string aInString)
		{
			string passPhrase = "GuXueFeng";
			string saltValue = "19800629";
			string hashAlgorithm = "SHA1";
			int passwordIterations = 2;
			string initVector = "@1B2c3D4e5F6g7H8";
			int keySize = 256;
			return NoteRemote.Decrypt(aInString, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
		}
		public static string GetNoteClientStartPath()
		{
			RegistryKey localMachine = Registry.LocalMachine;
			RegistryKey registryKey = localMachine.OpenSubKey("Software\\KSExpert", true);
			object value = registryKey.GetValue("NoteClientStartPath");
			string result;
			if (value == null)
			{
				result = "";
			}
			else
			{
				result = value.ToString();
			}
			return result;
		}
		public bool ConnectionTest()
		{
			return true;
		}
		private Array ChangeArrayLength(Array oriArray, int Count)
		{
			Type elementType = oriArray.GetType().GetElementType();
			Array array = Array.CreateInstance(elementType, Count);
			Array.Copy(oriArray, 0, array, 0, Math.Min(oriArray.Length, Count));
			return array;
		}
		private Array ChangeArrayLength(Array oriArray, int Row, int Col)
		{
			Type elementType = oriArray.GetType().GetElementType();
			Array array = Array.CreateInstance(elementType, Row, Col);
			Array.Copy(oriArray, 0, array, 0, Math.Min(oriArray.Length, Row * Col));
			return array;
		}
		private void GetServerPara()
		{
			this._address = this.IniReadValue("database", "address", Application.StartupPath + "\\NoteServer.ini");
			this._username = this.IniReadValue("database", "username", Application.StartupPath + "\\NoteServer.ini");
			this._pwd = this.IniReadValue("database", "pwd", Application.StartupPath + "\\NoteServer.ini");
			this._databasename = this.IniReadValue("database", "databasename", Application.StartupPath + "\\NoteServer.ini");
		}
		public bool UserReg(string aUserID, string aUserName, string aUserPwd, string aPwdAgain, string aDepID, string aGroupID, ref string aErrMsg)
		{
			string text = aUserID.Trim();
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				if (!dataBaseObject.Connected)
				{
					aErrMsg = "用户注册失败！服务器端数据库连接失败！";
					GC.Collect();
					result = false;
				}
				else
				{
					if (text != "")
					{
						string aStrSql = "select * from Employees where EmpID='" + text + "'";
						array = dataBaseObject.Open(aStrSql);
						if (dataBaseObject.Message != "")
						{
							aErrMsg = "用户注册失败！" + dataBaseObject.Message;
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							if (array.Length != 0)
							{
								aErrMsg = "用户注册失败！用户ID已存在，请重新选择！";
								dataBaseObject.DisConnect();
								GC.Collect();
								result = false;
							}
							else
							{
								if (aUserName.Trim() == "")
								{
									aErrMsg = "用户注册失败！用户名称不能为空！";
									dataBaseObject.DisConnect();
									GC.Collect();
									result = false;
								}
								else
								{
									if (aUserPwd.Trim() != aPwdAgain.Trim())
									{
										aErrMsg = "用户注册失败！输入的两次密码不一致！";
										dataBaseObject.DisConnect();
										GC.Collect();
										result = false;
									}
									else
									{
										if (aDepID.Trim() == "")
										{
											aErrMsg = "用户注册失败！部门ID不能为空！";
											dataBaseObject.DisConnect();
											GC.Collect();
											result = false;
										}
										else
										{
											aStrSql = "select * from Department where DepID=" + aDepID.Trim();
											array = dataBaseObject.Open(aStrSql);
											if (dataBaseObject.Message != "")
											{
												aErrMsg = "用户注册失败！" + dataBaseObject.Message;
												dataBaseObject.DisConnect();
												GC.Collect();
												result = false;
											}
											else
											{
												if (array.Length == 0)
												{
													aErrMsg = "用户注册失败！部门ID不存在，请重新选择！";
													dataBaseObject.DisConnect();
													GC.Collect();
													result = false;
												}
												else
												{
													if (aGroupID.Trim() == "")
													{
														aErrMsg = "用户注册失败！组ID不能为空！";
														dataBaseObject.DisConnect();
														GC.Collect();
														result = false;
													}
													else
													{
														aStrSql = "select * from WorkGroup where GroupID=" + aGroupID.Trim();
														array = dataBaseObject.Open(aStrSql);
														if (dataBaseObject.Message != "")
														{
															aErrMsg = "用户注册失败！" + dataBaseObject.Message;
															dataBaseObject.DisConnect();
															GC.Collect();
															result = false;
														}
														else
														{
															if (array.Length == 0)
															{
																aErrMsg = "用户注册失败！组ID不存在，请重新选择！";
																dataBaseObject.DisConnect();
																GC.Collect();
																result = false;
															}
															else
															{
																aStrSql = "select * from WorkGroup where GroupID=" + aGroupID.Trim() + " and DepID=" + aDepID;
																array = dataBaseObject.Open(aStrSql);
																if (dataBaseObject.Message != "")
																{
																	aErrMsg = "用户注册失败！" + dataBaseObject.Message;
																	dataBaseObject.DisConnect();
																	GC.Collect();
																	result = false;
																}
																else
																{
																	if (array.Length == 0)
																	{
																		aErrMsg = "用户注册失败！请求登记的部门ID和组ID不匹配，请重新选择！";
																		dataBaseObject.DisConnect();
																		GC.Collect();
																		result = false;
																	}
																	else
																	{
																		string text2 = NoteRemote.Encrypt(aUserID + aUserPwd);
																		aStrSql = string.Concat(new string[]
																		{
																			"insert into Employees(EmpID,EmpName,EmpPwd,DepID,GroupID,PurID,RecordState) values('",
																			aUserID,
																			"','",
																			aUserName,
																			"','",
																			text2,
																			"',",
																			aDepID,
																			",",
																			aGroupID,
																			",2,0)"
																		});
																		int num = dataBaseObject.ExecSQL(aStrSql);
																		if (dataBaseObject.Message != "" || num != 1)
																		{
																			aErrMsg = "用户注册失败！" + dataBaseObject.Message;
																			dataBaseObject.DisConnect();
																			GC.Collect();
																			result = false;
																		}
																		else
																		{
																			dataBaseObject.DisConnect();
																			GC.Collect();
																			result = true;
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
					else
					{
						aErrMsg = "用户注册失败！用户ID不能为空，请重新选择！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
				}
			}
			else
			{
				aErrMsg = "用户注册失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool UserLogin(string aUserID, string aUserPwd, ref object[] aLoginInfo, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			aLoginInfo = (object[])this.ChangeArrayLength(aLoginInfo, 6);
			for (int i = 0; i < 6; i++)
			{
				aLoginInfo[i] = new object();
			}
			aLoginInfo[0] = false;
			aLoginInfo[1] = "";
			aLoginInfo[2] = "";
			aLoginInfo[3] = "";
			aLoginInfo[4] = "";
			aLoginInfo[5] = "";
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select * from Employees where upper(EmpID)='" + aUserID.ToUpper() + "'";
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "用户登录失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (array.Length == 0)
					{
						aErrMsg = "用户登录失败！不存在此用户！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						aStrSql = "select * from Employees where RecordState=0 and upper(EmpID)='" + aUserID.ToUpper() + "'";
						array = dataBaseObject.Open(aStrSql);
						if (dataBaseObject.Message != "")
						{
							aErrMsg = "用户登录失败！" + dataBaseObject.Message;
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							if (array.Length == 0)
							{
								aErrMsg = "用户登录失败！此用户已被停用！";
								dataBaseObject.DisConnect();
								GC.Collect();
								result = false;
							}
							else
							{
								string text = NoteRemote.Encrypt(aUserID + aUserPwd);
								aStrSql = string.Concat(new string[]
								{
									"select EmpID,EmpName,DepID,GroupID,PurID from Employees where upper(EmpID)='",
									aUserID.ToUpper(),
									"' and EmpPwd='",
									text,
									"'"
								});
								array = dataBaseObject.Open(aStrSql);
								if (dataBaseObject.Message != "")
								{
									aErrMsg = "用户登录失败！" + dataBaseObject.Message;
									dataBaseObject.DisConnect();
									GC.Collect();
									result = false;
								}
								else
								{
									if (array.Length == 0)
									{
										aErrMsg = "用户登录失败！用户密码不正确！";
										dataBaseObject.DisConnect();
										GC.Collect();
										result = false;
									}
									else
									{
										int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
										int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
										aLoginInfo[0] = true;
										aLoginInfo[1] = array[0, 0];
										aLoginInfo[2] = array[0, 1];
										aLoginInfo[3] = array[0, 2];
										aLoginInfo[4] = array[0, 3];
										aLoginInfo[5] = array[0, 4];
										dataBaseObject.DisConnect();
										GC.Collect();
										result = true;
									}
								}
							}
						}
					}
				}
			}
			else
			{
				aErrMsg = "用户登录失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetUserName(string aUserID, ref string aUserName, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select EmpName from Employees where upper(EmpID)='" + aUserID.ToUpper() + "'";
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "获取用户姓名失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (array.Length == 0)
					{
						aErrMsg = "获取用户姓名失败！不存在此用户！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						aUserName = array[0, 0];
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "获取用户姓名失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool ClearUserPwd(string aUserID, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select * from Employees where upper(EmpID)='" + aUserID.ToUpper() + "'";
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "用户密码清空失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (array.Length == 0)
					{
						aErrMsg = "用户密码清空失败！用户ID不存在，请确认是否输入了错误的用户ID！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						string text = NoteRemote.Encrypt(aUserID ?? "");
						aStrSql = string.Concat(new string[]
						{
							"update Employees set EmpPwd='",
							text,
							"' where upper(EmpID)='",
							aUserID.ToUpper(),
							"'"
						});
						int num = dataBaseObject.ExecSQL(aStrSql);
						if (dataBaseObject.Message != "" || num != 1)
						{
							aErrMsg = "用户密码清空失败！" + dataBaseObject.Message;
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							dataBaseObject.DisConnect();
							GC.Collect();
							result = true;
						}
					}
				}
			}
			else
			{
				aErrMsg = "用户密码清空失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool EditNote(string aUserID, string aNoteTopic, string aNoteBody, string aNoteDate, string aWorkLoad, string aBeginTime, string aEndTime, string aOldNoteID, bool aIsNewNote, string aTaskID, string aParaString, string aParaCount, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				if (aUserID.Trim() == "")
				{
					aErrMsg = "日志保存失败！用户ID不能为空！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					string aStrSql = "select * from Employees where EmpID='" + aUserID.Trim() + "'";
					array = dataBaseObject.Open(aStrSql);
					if (dataBaseObject.Message != "")
					{
						aErrMsg = "日志保存失败！" + dataBaseObject.Message;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						if (array.Length == 0)
						{
							aErrMsg = "日志保存失败！用户ID不存在！";
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							if (aNoteTopic.Trim() == "")
							{
								aErrMsg = "日志保存失败！日志主题不能为空！";
								dataBaseObject.DisConnect();
								GC.Collect();
								result = false;
							}
							else
							{
								if (aNoteBody.Trim() == "")
								{
									aErrMsg = "日志保存失败！日志正文不能为空！";
									dataBaseObject.DisConnect();
									GC.Collect();
									result = false;
								}
								else
								{
									if (aNoteDate.Trim() == "")
									{
										aErrMsg = "日志保存失败！日志日期不能为空！";
										dataBaseObject.DisConnect();
										GC.Collect();
										result = false;
									}
									else
									{
										if (!aIsNewNote)
										{
											aStrSql = string.Concat(new string[]
											{
												"exec usp_wn_editworknote @flag = 0,@userid = '",
												aUserID,
												"',@notetopic = '",
												aNoteTopic,
												"',@notebody = '",
												aNoteBody,
												"',@notedate = '",
												aNoteDate,
												"',@workload = '",
												aWorkLoad,
												"',@begintime = '",
												aBeginTime,
												"',@endtime = '",
												aEndTime,
												"',@oldnoteid = '",
												aOldNoteID,
												"',@taskid = ",
												aTaskID,
												",@ParaString = '",
												aParaString,
												"',@ParaCount = ",
												aParaCount
											});
										}
										else
										{
											aStrSql = string.Concat(new string[]
											{
												"exec usp_wn_editworknote @flag = 1,@userid = '",
												aUserID,
												"',@notetopic = '",
												aNoteTopic,
												"',@notebody = '",
												aNoteBody,
												"',@notedate = '",
												aNoteDate,
												"',@workload = '",
												aWorkLoad,
												"',@begintime = '",
												aBeginTime,
												"',@endtime = '",
												aEndTime,
												"',@oldnoteid = '',@taskid = ",
												aTaskID,
												",@ParaString = '",
												aParaString,
												"',@ParaCount = ",
												aParaCount
											});
										}
										array = new string[0, 0];
										array = dataBaseObject.Open(aStrSql);
										if (dataBaseObject.Message != "")
										{
											aErrMsg = dataBaseObject.Message;
											dataBaseObject.DisConnect();
											GC.Collect();
											result = false;
										}
										else
										{
											if (array[0, 0] == "F")
											{
												aErrMsg = array[0, 1];
												dataBaseObject.DisConnect();
												GC.Collect();
												result = false;
											}
											else
											{
												dataBaseObject.DisConnect();
												GC.Collect();
												result = true;
											}
										}
									}
								}
							}
						}
					}
				}
			}
			else
			{
				aErrMsg = "日志保存失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetLastNewNoteID(string aUserID, string aNoteDate, ref string aNewNoteID, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"select isnull(max(NoteID),0) from WorkNotes(nolock) where EmpID='",
					aUserID,
					"' and NoteDate = '",
					aNoteDate,
					"'"
				});
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "取得新增日志的日志编号失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					aNewNoteID = array[0, 0];
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "取得新增日志的日志编号失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetNoteListGroupByYearMonth(string aUserID, ref string[] aNoteList, string aReturnMonths, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"select distinct Left(NoteDate,7) from WorkNotes(nolock) where RecordState = 0 and EmpID='",
					aUserID,
					"' and Left(NoteDate,7) in (",
					aReturnMonths,
					") order by Left(NoteDate,7) desc"
				});
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询日志列表失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					aNoteList = (string[])this.ChangeArrayLength(aNoteList, num);
					for (int i = 0; i <= num - 1; i++)
					{
						aNoteList[i] = array[i, 0];
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询日志列表失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetNoteListByYearMonth(string aUserID, string aNoteDate, ref string[,] aNoteList, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"select Right(a.NoteDate,2),a.NoteID,a.NoteState,a.NoteTopic,a.NoteDate,a.WorkLoad,sum(b.WorkLoad) from WorkNotes a(nolock),WorkNote b(nolock) where a.EmpID = b.EmpID and        a.NoteDate = b.NoteDate and        a.RecordState = 0 and a.EmpID='",
					aUserID,
					"' and Left(a.NoteDate,7)='",
					aNoteDate,
					"' group by a.NoteID,a.NoteState,a.NoteTopic,a.NoteDate,a.WorkLoad order by a.NoteDate"
				});
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询日志列表失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aNoteList = (string[,])this.ChangeArrayLength(aNoteList, num, num2);
					for (int i = 0; i <= num - 1; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aNoteList[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询日志列表失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetNoteInfo(string aNoteID, ref string[] aNoteItem, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select NoteID,EmpID,NoteTopic,NoteBody,NoteDate,WorkLoad,NoteState,CreateDate,CreateTime,NoteMemo,Auditor,AuditDate,AuditTime,BeginTime,EndTime,isnull(TaskID,0),Address,Hoapital from WorkNotes(nolock) where RecordState = 0 and NoteID = " + aNoteID;
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询日志详细信息失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					if (num == 0)
					{
						aErrMsg = "没有编号<" + aNoteID + ">的详细日志信息！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						if (num >= 2)
						{
							aErrMsg = "编号<" + aNoteID + ">的详细日志信息记录多于1条！";
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							aNoteItem = (string[])this.ChangeArrayLength(aNoteItem, num2);
							for (int i = 0; i <= num2 - 1; i++)
							{
								aNoteItem[i] = array[0, i];
							}
							dataBaseObject.DisConnect();
							GC.Collect();
							result = true;
						}
					}
				}
			}
			else
			{
				aErrMsg = "查询日志详细信息失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetDownLoadDetailNoteCount(string aUserID, string aBeginDate, string aEndDate, ref int DetailNoteCount, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text = string.Concat(new string[]
				{
					"exec usp_wn_downloaddetailnotes 0,'",
					aUserID,
					"','",
					aBeginDate,
					"','",
					aEndDate,
					"'"
				});
				array = dataBaseObject.Open(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询用户日志信息失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (!int.TryParse(array[0, 0], out DetailNoteCount))
					{
						DetailNoteCount = 0;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "获取日志明细个数失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool DownLoadDetailNote(string aUserID, string aBeginDate, string aEndDate, ref string[,] aNoteItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text = string.Concat(new string[]
				{
					"exec usp_wn_downloaddetailnotes 1,'",
					aUserID,
					"','",
					aBeginDate,
					"','",
					aEndDate,
					"'"
				});
				array = dataBaseObject.Open(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询用户日志信息失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aNoteItems = (string[,])this.ChangeArrayLength(aNoteItems, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aNoteItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "下载用户日志数据失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetDetailNoteList(string aUserID, string aNoteState, string aNoteYearMonth, ref string[,] aNoteItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text;
				if (aNoteState == "")
				{
					if (aNoteYearMonth.Length == 4)
					{
						text = string.Concat(new string[]
						{
							"exec usp_wn_getdetailnotelist @flag = 0,@userid = '",
							aUserID,
							"',@noteyearmonth = '",
							aNoteYearMonth,
							"'"
						});
					}
					else
					{
						text = string.Concat(new string[]
						{
							"exec usp_wn_getdetailnotelist @flag = 1,@userid = '",
							aUserID,
							"',@noteyearmonth = '",
							aNoteYearMonth,
							"'"
						});
					}
					text += ",@notestate = null";
				}
				else
				{
					if (aNoteYearMonth.Length == 4)
					{
						text = string.Concat(new string[]
						{
							"exec usp_wn_getdetailnotelist @flag = 2,@userid = '",
							aUserID,
							"',@noteyearmonth = '",
							aNoteYearMonth,
							"'"
						});
					}
					else
					{
						text = string.Concat(new string[]
						{
							"exec usp_wn_getdetailnotelist @flag = 3,@userid = '",
							aUserID,
							"',@noteyearmonth = '",
							aNoteYearMonth,
							"'"
						});
					}
					text = text + ",@notestate = " + aNoteState;
				}
				array = dataBaseObject.Open(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询用户日志信息失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aNoteItems = (string[,])this.ChangeArrayLength(aNoteItems, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aNoteItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询用户日志信息失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetNoteMasterList(string aUserID, string aNoteState, string aNoteYearMonth, ref string[,] aNoteItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text;
				if (aNoteYearMonth == "")
				{
					text = "select NoteID,NoteDate,WorkLoad,NoteState,CreateDate,CreateTime,Auditor,AuditDate,AuditTime,AuditWorkLoad,NoteMemo from WorkNote(nolock) where RecordState = 0 and EmpID = '" + aUserID + "'";
				}
				else
				{
					if (aNoteYearMonth.Length == 4)
					{
						text = string.Concat(new string[]
						{
							"select NoteID,NoteDate,WorkLoad,NoteState,CreateDate,CreateTime,Auditor,AuditDate,AuditTime,AuditWorkLoad,NoteMemo from WorkNote(nolock) where RecordState = 0 and EmpID = '",
							aUserID,
							"' and Left(NoteDate,4)='",
							aNoteYearMonth,
							"'"
						});
					}
					else
					{
						text = string.Concat(new string[]
						{
							"select NoteID,NoteDate,WorkLoad,NoteState,CreateDate,CreateTime,Auditor,AuditDate,AuditTime,AuditWorkLoad,NoteMemo from WorkNote(nolock) where RecordState = 0 and EmpID = '",
							aUserID,
							"' and Left(NoteDate,7)='",
							aNoteYearMonth,
							"'"
						});
					}
				}
				if (!(aNoteState == ""))
				{
					text = text + " and NoteState=" + aNoteState;
				}
				array = dataBaseObject.Open(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询用户日志信息失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aNoteItems = (string[,])this.ChangeArrayLength(aNoteItems, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aNoteItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询用户日志信息失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool AlterUserPwd(string aUserID, string aOldPwd, string aNewPwd, string aPwdAgain, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select * from Employees where EmpID='" + aUserID.Trim() + "'";
				array = dataBaseObject.Open(aStrSql);
				if (array.Length == 0)
				{
					aErrMsg = "密码修改失败！不存在此用户！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					string text = NoteRemote.Encrypt(aUserID + aOldPwd);
					aStrSql = string.Concat(new string[]
					{
						"select * from Employees where EmpID='",
						aUserID.Trim(),
						"' and EmpPwd='",
						text,
						"'"
					});
					array = dataBaseObject.Open(aStrSql);
					if (array.Length == 0)
					{
						aErrMsg = "密码修改失败！原密码错误！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						if (aNewPwd.Trim() != aPwdAgain.Trim())
						{
							aErrMsg = "密码修改失败！输入的两次密码不一致！";
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							string text2 = NoteRemote.Encrypt(aUserID + aNewPwd.Trim());
							aStrSql = string.Concat(new string[]
							{
								"update Employees set EmpPwd='",
								text2,
								"' where EmpID='",
								aUserID.Trim(),
								"'"
							});
							int num = dataBaseObject.ExecSQL(aStrSql);
							if (num != 1)
							{
								aErrMsg = "密码修改失败！" + dataBaseObject.Message;
								dataBaseObject.DisConnect();
								GC.Collect();
								result = false;
							}
							else
							{
								dataBaseObject.DisConnect();
								GC.Collect();
								result = true;
							}
						}
					}
				}
			}
			else
			{
				aErrMsg = "密码修改失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool DeleteNote(string aNoteID, ref string aErrMsg)
		{
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "exec usp_wn_delworknote '" + aNoteID + "'";
				string[,] array = new string[0, 0];
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (array[0, 0] == "F")
					{
						aErrMsg = array[0, 1];
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "日志删除失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetUserList(string aUserID, string aDepID, string aGroupID, string aPurviewID, ref string[,] aUserItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql;
				if (aDepID == "" && aGroupID == "" && aPurviewID == "0")
				{
					aStrSql = "exec usp_wn_getuserlist 0";
				}
				else
				{
					if (aDepID != "" && aGroupID != "" && aPurviewID == "1")
					{
						aStrSql = string.Concat(new string[]
						{
							"exec usp_wn_getuserlist 1,'",
							aUserID,
							"','",
							aDepID,
							"','",
							aGroupID,
							"'"
						});
					}
					else
					{
						if (aDepID != "" && aGroupID != "" && aPurviewID == "3")
						{
							aStrSql = "exec usp_wn_getuserlist 3";
						}
						else
						{
							if (!(aDepID != "") || !(aGroupID != "") || !(aPurviewID == "4"))
							{
								aErrMsg = "查询系统用户列表失败！数据库数据值异常！部门ID、组ID和权限ID值不匹配！";
								GC.Collect();
								result = false;
								return result;
							}
							aStrSql = "exec usp_wn_getuserlist 4,'" + aUserID + "'";
						}
					}
				}
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询系统用户列表失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aUserItems = (string[,])this.ChangeArrayLength(aUserItems, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aUserItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询系统用户列表失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetNeedAuditUserList(string aDepID, string aGroupID, string aPurviewID, ref string[,] aUserItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql;
				if (aDepID == "" && aGroupID == "" && aPurviewID == "0")
				{
					aStrSql = "select a.EmpID,a.EmpName,a.DepID,b.DepName,a.GroupID,c.GroupName,a.PurID,d.PurName from Employees a,Department b,WorkGroup c,Purview d where a.RecordState = 0 and a.DepID = b.DepID and a.GroupID = c.GroupID and a.PurID = d.PurID";
				}
				else
				{
					if (!(aDepID != "") || !(aGroupID != ""))
					{
						aErrMsg = "查询系统用户列表失败！数据库数据值异常！部门ID、组ID和权限ID值不匹配！";
						GC.Collect();
						result = false;
						return result;
					}
					aStrSql = "select a.EmpID,a.EmpName,a.DepID,b.DepName,a.GroupID,c.GroupName,a.PurID,d.PurName from Employees a,Department b,WorkGroup c,Purview d where a.RecordState = 0 and a.DepID = b.DepID and a.GroupID = c.GroupID and a.PurID = d.PurID and a.DepID=" + aDepID;
				}
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询系统用户列表失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aUserItems = (string[,])this.ChangeArrayLength(aUserItems, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aUserItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询系统用户列表失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool NoteAudit(string aNoteIDs, string aNoteNewState, string aInfoText, string aAuditor, string aAuditWorkLoad, ref string aErrMsg)
		{
			if (aAuditWorkLoad.Trim() == "")
			{
			}
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"exec usp_wn_noteaudit ",
					aNoteNewState,
					",'",
					aNoteIDs,
					"','",
					aInfoText,
					"','",
					aAuditor,
					"',",
					aAuditWorkLoad
				});
				string[,] array = new string[0, 0];
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (array[0, 0] == "F")
					{
						aErrMsg = array[0, 1];
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "日志审核标志更新失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool SetUserPurview(string aUserID, string aPurviewID, ref string aErrMsg)
		{
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"update Employees set PurID = ",
					aPurviewID,
					" where EmpID = '",
					aUserID,
					"'"
				});
				int num = dataBaseObject.ExecSQL(aStrSql);
				if (num != 1)
				{
					aErrMsg = "用户角色设置失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "用户角色设置失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool SetUserState(string aUserID, ref string aErrMsg)
		{
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "update Employees set RecordState = 1 where EmpID = '" + aUserID + "'";
				int num = dataBaseObject.ExecSQL(aStrSql);
				if (num != 1)
				{
					aErrMsg = "用户状态设置失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					aStrSql = "update WorkNote set RecordState = 1 where EmpID = '" + aUserID + "'";
					num = dataBaseObject.ExecSQL(aStrSql);
					if (dataBaseObject.Message != "")
					{
						aErrMsg = "用户状态设置失败！" + dataBaseObject.Message;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						aStrSql = "update WorkNotes set RecordState = 1 where EmpID = '" + aUserID + "'";
						num = dataBaseObject.ExecSQL(aStrSql);
						if (dataBaseObject.Message != "")
						{
							aErrMsg = "用户状态设置失败！" + dataBaseObject.Message;
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							dataBaseObject.DisConnect();
							GC.Collect();
							result = true;
						}
					}
				}
			}
			else
			{
				aErrMsg = "用户状态设置失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool ChangeUserGroup(string aUserID, string aNewGroupID, ref string aErrMsg)
		{
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"update Employees set GroupID = '",
					aNewGroupID,
					"' where EmpID = '",
					aUserID,
					"'"
				});
				int num = dataBaseObject.ExecSQL(aStrSql);
				if (num != 1)
				{
					aErrMsg = "用户转组失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "用户状态设置失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool CreateAuditFeedBackMessage(string aAuditerID, string aOwnerID, string aNoteDate, string aFeedBackBody, string aSenderID, ref string aErrMsg)
		{
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = string.Concat(new string[]
				{
					"insert into WorkNoteAuditFeedBack(AuditerID,OwnerID,NoteDate,FeedBackBody,RecordState,SenderID,SendDate,SendTime) select '",
					aAuditerID,
					"','",
					aOwnerID,
					"','",
					aNoteDate,
					"','",
					aFeedBackBody,
					"',0,'",
					aSenderID,
					"','",
					DateTime.Now.ToString("yyyy-MM-dd"),
					"','",
					DateTime.Now.ToString("HH:mm:ss"),
					"'"
				});
				int num = dataBaseObject.ExecSQL(aStrSql);
				if (num != 1)
				{
					aErrMsg = "创建日志审核复核反馈信息失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "创建日志审核复核反馈信息失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetWorkNoteAuditFeedBack(string aAuditerID, ref string[,] aFeedBacks, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text = "select a.xh,a.AuditerID,b.EmpName,a.OwnerID,c.EmpName,a.NoteDate,a.FeedBackBody,d.EmpName,a.SendDate,a.SendTime from WorkNoteAuditFeedBack a(nolock),Employees b(nolock),Employees c(nolock),Employees d(nolock) where isnull(a.RecordState,0) = 0 and a.AuditerID='" + aAuditerID + "' and a.AuditerID = b.EmpID and a.OwnerID = c.EmpID and a.SenderID = d.EmpID";
				array = dataBaseObject.Open(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询审核复核反馈信息失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aFeedBacks = (string[,])this.ChangeArrayLength(aFeedBacks, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aFeedBacks[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询审核复核反馈信息失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool SetWorkNoteAuditFeedBack(string aFeedBackIndex, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text = string.Concat(new string[]
				{
					"update WorkNoteAuditFeedBack set DealDate = '",
					DateTime.Now.ToString("yyyy-MM-dd"),
					"',DealTime = '",
					DateTime.Now.ToString("HH:mm:ss"),
					"',RecordState = 1 where xh=",
					aFeedBackIndex
				});
				int num = dataBaseObject.ExecSQL(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "设置审核复核反馈信息状态失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (num <= 0)
					{
						aErrMsg = "设置审核复核反馈信息状态失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "设置审核复核反馈信息状态失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetNotPassedNoteList(string aUserID, ref string[,] aNoteItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string text = "select NoteID,EmpID,NoteTopic,NoteBody,NoteDate,WorkLoad,NoteState,CreateDate,CreateTime,NoteMemo,Auditor,AuditDate,AuditTime from WorkNotes where EmpID = '" + aUserID + "' and NoteState=2";
				array = dataBaseObject.Open(text);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询用户被置疑的日志失败！" + dataBaseObject.Message + "\nSQL语句=" + text;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aNoteItems = (string[,])this.ChangeArrayLength(aNoteItems, num, num2);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aNoteItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询用户被置疑的日志失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool AddDepartment(string aDepName, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				if (aDepName.Trim() == "")
				{
					aErrMsg = "部门增加失败！部门名称不能为空！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					string aStrSql = "select * from Department where DepName='" + aDepName + "'";
					array = dataBaseObject.Open(aStrSql);
					if (array.Length != 0)
					{
						aErrMsg = "部门增加失败！存在同名部门名称，请重新选择！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						aStrSql = "insert into Department(DepName) values('" + aDepName + "')";
						int num = dataBaseObject.ExecSQL(aStrSql);
						if (num != 1)
						{
							aErrMsg = "部门增加失败！" + dataBaseObject.Message;
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							dataBaseObject.DisConnect();
							GC.Collect();
							result = true;
						}
					}
				}
			}
			else
			{
				aErrMsg = "部门增加失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool AddGroup(string aGroupName, string aDepID, string aParentGroupID, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				if (aGroupName.Trim() == "")
				{
					aErrMsg = "组增加失败！组名称不能为空！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					if (aDepID.Trim() == "")
					{
						aErrMsg = "组增加失败！部门ID不能为空！";
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						string aStrSql = "select * from WorkGroup where GroupName='" + aGroupName + "' and DepID=" + aDepID;
						array = dataBaseObject.Open(aStrSql);
						if (array.Length != 0)
						{
							aErrMsg = "组增加失败！同一部门下不能存在同名组，请重新选择！";
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							aStrSql = string.Concat(new string[]
							{
								"insert into WorkGroup(GroupName,DepID,ParentGroupID) values('",
								aGroupName,
								"',",
								aDepID,
								",'",
								aParentGroupID,
								"')"
							});
							int num = dataBaseObject.ExecSQL(aStrSql);
							if (num != 1)
							{
								aErrMsg = "部门增加失败！" + dataBaseObject.Message;
								dataBaseObject.DisConnect();
								GC.Collect();
								result = false;
							}
							else
							{
								dataBaseObject.DisConnect();
								GC.Collect();
								result = true;
							}
						}
					}
				}
			}
			else
			{
				aErrMsg = "组增加失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetDepartmentList(ref string[,] aDepartmentList, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select DepID,DepName from Department";
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = "查询部门数据失败！" + dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aDepartmentList = (string[,])this.ChangeArrayLength(aDepartmentList, num, num2);
					for (int i = 0; i <= num - 1; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aDepartmentList[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "查询部门数据失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool CommonQuery(string aStrSql, ref string[,] aDataItems, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				array = dataBaseObject.Open(aStrSql);
				if (dataBaseObject.Message != "")
				{
					aErrMsg = dataBaseObject.Message;
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
					aDataItems = (string[,])this.ChangeArrayLength(aDataItems, num, num2);
					for (int i = 0; i <= num - 1; i++)
					{
						for (int j = 0; j <= num2 - 1; j++)
						{
							aDataItems[i, j] = array[i, j];
						}
					}
					dataBaseObject.DisConnect();
					GC.Collect();
					result = true;
				}
			}
			else
			{
				aErrMsg = "不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool GetGroupList(string aDepID, ref string[,] aGroupList, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				if (aDepID.Trim() == "")
				{
					aErrMsg = "查询组数据失败！部门ID不能为空！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					string aStrSql = "select a.GroupID,a.GroupName,b.GroupID,b.GroupName from WorkGroup a(nolock),WorkGroup b(nolock) where a.ParentGroupID *= b.GroupID and a.DepID=" + aDepID;
					array = dataBaseObject.Open(aStrSql);
					if (dataBaseObject.Message != "")
					{
						aErrMsg = "查询组数据失败！" + dataBaseObject.Message;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
						int num2 = array.GetUpperBound(1) - array.GetLowerBound(1) + 1;
						aGroupList = (string[,])this.ChangeArrayLength(aGroupList, num, num2);
						for (int i = 0; i <= num - 1; i++)
						{
							for (int j = 0; j <= num2 - 1; j++)
							{
								aGroupList[i, j] = array[i, j];
							}
						}
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "查询组数据失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool DelDepartment(string aDepID, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select * from Employees where DepID = " + aDepID;
				array = dataBaseObject.Open(aStrSql);
				if (array.Length != 0)
				{
					aErrMsg = "部门删除失败！此部门下已有用户登记！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					aStrSql = "delete from Department where DepID=" + aDepID;
					int num = dataBaseObject.ExecSQL(aStrSql);
					if (num != 1)
					{
						aErrMsg = "部门删除失败！" + dataBaseObject.Message;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						aStrSql = "delete from WorkGroup where DepID=" + aDepID;
						num = dataBaseObject.ExecSQL(aStrSql);
						if (dataBaseObject.Message != "")
						{
							aErrMsg = "删除部门下组数据失败！" + dataBaseObject.Message;
							dataBaseObject.DisConnect();
							GC.Collect();
							result = false;
						}
						else
						{
							dataBaseObject.DisConnect();
							GC.Collect();
							result = true;
						}
					}
				}
			}
			else
			{
				aErrMsg = "部门删除失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
		public bool DelGroup(string aGroupID, ref string aErrMsg)
		{
			string[,] array = new string[0, 0];
			bool result;
			if (this.iDataBaseMode == NoteRemote.TDataBaseMode.dbmSqlServer)
			{
				DataBaseObject dataBaseObject = new SqlServerDBObject();
				dataBaseObject = (dataBaseObject as SqlServerDBObject);
				this.GetServerPara();
				(dataBaseObject as SqlServerDBObject).Connect(this._address, this._username, this._pwd, this._databasename);
				string aStrSql = "select * from Employees where GroupID = " + aGroupID;
				array = dataBaseObject.Open(aStrSql);
				if (array.Length != 0)
				{
					aErrMsg = "组删除失败！此组下已有用户登记！";
					dataBaseObject.DisConnect();
					GC.Collect();
					result = false;
				}
				else
				{
					aStrSql = "delete from WorkGroup where GroupID=" + aGroupID;
					int num = dataBaseObject.ExecSQL(aStrSql);
					if (num != 1)
					{
						aErrMsg = "组删除失败！" + dataBaseObject.Message;
						dataBaseObject.DisConnect();
						GC.Collect();
						result = false;
					}
					else
					{
						dataBaseObject.DisConnect();
						GC.Collect();
						result = true;
					}
				}
			}
			else
			{
				aErrMsg = "组删除失败！不支持服务器端设置的数据库类型！";
				GC.Collect();
				result = false;
			}
			return result;
		}
	}
}
